package com.ioe.p2p.pojo;

import java.net.DatagramPacket;
import java.nio.charset.StandardCharsets;
import java.util.UUID;

public final class User{

    private String _id;

    private String _username;

    private String _msg;

    private String _ip;

    private String _port;

    User(){

    }

    public User(DatagramPacket dp){
        User user = new User();
        user.set_username(new String(dp.getData(), StandardCharsets.UTF_8).split(";")[0]);
        user.set_id(UUID.randomUUID().toString().replaceAll("-", ""));
        user.set_ip(dp.getAddress().getHostAddress());
        user.set_port(String.valueOf(dp.getPort()));
    }

    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String get_username() {
        return _username;
    }

    public void set_username(String _username) {
        this._username = _username;
    }

    public String get_msg() {
        return _msg;
    }

    public void set_msg(String _msg) {
        this._msg = _msg;
    }

    public String get_ip() {
        return _ip;
    }

    public void set_ip(String _ip) {
        this._ip = _ip;
    }

    public String get_port() {
        return _port;
    }

    public void set_port(String _port) {
        this._port = _port;
    }
}